<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<LinQDemo.Models.Student>>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void ClassID_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Auto Click when select Combobox......Invisible Button 
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ListStudentByClass</title>
</head>
<body>
    <form id="form1" runat="server">

    <asp:DropDownList ID="ClassID" runat="server" 
                    DataSourceID="LinqDataSource1" DataTextField="ClassID" 
                    DataValueField="ClassID" 
        onselectedindexchanged="ClassID_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                    ContextTypeName="LinQDemo.Models.LinQDemoDataContext" OrderBy="ClassID" 
                    Select="new (ClassID)" TableName="Classes">
                </asp:LinqDataSource>
                
                    <asp:Button ID="Submit" runat="server"  Text="View" />

    <table>
        
        <tr>
            <th></th>
            <th>
                StudentID
            </th>
            <th>
                StudentName
            </th>
            <th>
                ClassID
            </th>
            <th>
                IsValid
            </th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>
            <td>
                <%= Html.ActionLink("Edit", "Edit", new { id=item.StudentID.Trim()  }) %> |
            </td>
            <td>
                <%= Html.Encode(item.StudentID) %>
            </td>
            <td>
                <%= Html.Encode(item.StudentName) %>
            </td>
            <td>
                <%= Html.Encode(item.ClassID) %>
            </td>
            <td>
                <%= Html.Encode(item.IsValid) %>
            </td>
        </tr>
    
    <% } %>

    </table>
        </form>
    
</body>
</html>

